home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / trace1a.arc / TRACE11.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-02-04  |  41.5 KB  |  1,399 lines

  1.            page    60,132
  2.            .lfcond
  3.            title   "TRACE - Interrupt Tracer"
  4.            subttl  Introduction
  5.            page
  6. code       segment para public 'code'
  7.            assume  cs:code,ds:code
  8.            public  selvideo,selprint,print,print_hex,print_word,print_wordb
  9.            public  crlf,print_line,print_seg,print_edit,print_dec,table_print
  10.            public  feed,key,zap_hits
  11.  
  12.            extrn   prt_base:word,trace_table:byte,trace_curr:word,ict_index:word
  13.  
  14.            public  pick_ict,do_traces,do_enable,do_fcb,dump_buf,bin_to_bit
  15.            public  dump_rec,dump_before,dump_after,dump_flags,dump_fcb
  16.            public  dump_asciiz,ict_dump,disp_active
  17.  
  18.            extrn   rec_sizes:word,interp:near
  19.  
  20.            include trace1e.aic
  21. prt_flag   db   0                    ;flag: printer (1) or Screen (2) 
  22.            subttl  Support routines - Printer & Screen I/O
  23.            page
  24. ;*****************************************
  25. ;
  26. ; Select video for subsequent output
  27. ;
  28. ;*****************************************
  29.  
  30. selvmsg  db      cr,lf,"TRACE output routed to CRT screen",cr,lf,"$"
  31. selvideo proc    near
  32.          mov     prt_flag,0
  33.          push    dx
  34.          mov     dx,offset selvmsg
  35.          call    print_line
  36.          pop     dx
  37.          ret
  38. selvideo endp
  39.  
  40.  
  41. ;*****************************************
  42. ;
  43. ; Select printer for subsequent output
  44. ;
  45. ;*****************************************
  46.  
  47. selpmsg    db    cr,lf,"TRACE output routed to printer",cr,lf,"$"
  48. selpnomsg  db    cr,lf,"Printer not found",cr,lf,"$"
  49. selprint proc    near
  50.          push    ax
  51.          mov     ax,prt_base     ;do we have a printer?
  52.          or      al,ah
  53.          jz      selprint_no_printer
  54.  
  55.          push    dx
  56.          mov     dx,offset selpmsg
  57.          call    print_line
  58.          pop     dx
  59.          mov     prt_flag,al     ;al is non-zero if we do
  60.          jmp     selprint_exit
  61. selprint_no_printer:
  62.          push    dx
  63.          mov     dx,offset selpnomsg
  64.          call    print_line
  65.          pop     dx
  66. selprint_exit:
  67.          pop     ax
  68.          ret
  69. selprint endp
  70.  
  71. ;********************************************************
  72. ;
  73. ; Output AL to printer or screen, depending on prt_flag.
  74. ;
  75. ;********************************************************
  76.  
  77. print   proc    near
  78.         push    dx
  79.         push    cx
  80.         push    bx
  81.         push    ax
  82.  
  83. ; ----- See if it should go to printer
  84.  
  85.         test    prt_flag,0ffh           ;send it to printer?
  86.         jnz     print1                  ;yes
  87.  
  88. print0:
  89.  
  90. ;
  91. ; Send char to video via INT 010H
  92. ;
  93.  
  94.         mov     bl,1
  95.         mov     ah,14                   ;"Write TTY" func
  96.         int     010h
  97.         clc                             ;show no I/O error
  98.         jmp     short print9
  99.  
  100. print1:
  101.  
  102. ;----- Send it to printer
  103.  
  104.         mov     dx,prt_base             ;get printer base I/O address
  105.         inc     dx                      ;up to status port
  106.         mov     ah,al                   ;save char in ah
  107.         xor     cx,cx                   ;init timeout ticker
  108.  
  109. print2:
  110.         in      al,dx                   ;get status
  111.         test    al,080h                 ;is printer busy?
  112.         jnz     print5                  ;no, proceed to send char
  113.  
  114. ;
  115. ; We're not immediately ready. Some printers require more of a wait than
  116. ; the simple 64K loop found in CX. So here's a time waster that you may
  117. ; want to tailor to your printer.
  118. ;
  119.  
  120.         mov     al,8                    ;greatly extend timeout value
  121.  
  122. print3:
  123.         dec     al
  124.         jnz     print3
  125.  
  126.         loop    print2                  ;wait for whole timeout
  127.         stc                             ;set carry for timeout
  128.         jmp     short print9            ;and exit
  129.  
  130. print5:
  131.         dec     dx                      ;down to data reg
  132.         mov     al,ah                   ;recover char to be sent
  133.         out     dx,al                   ;put it on data lines
  134.         inc     dx                      ;up to control port
  135.         inc     dx
  136.         mov     al,0dh                  ;set strobe low
  137.         out     dx,al
  138.         mov     al,0ch                  ;set strobe high again
  139.         out     dx,al
  140.         clc                             ;show no error
  141.  
  142. print9:
  143.  
  144. ;
  145. ; At this point, CARRY is SET if we were going to the printer and had an
  146. ; I/O error.
  147. ;
  148.  
  149.         jnc     print10                 ;no error
  150.         call    selvideo                ;error, so switch to video
  151.         pop     ax                      ;recover AL
  152.         push    ax
  153.         jmp     print0                  ;go send it to video
  154.  
  155. print10:
  156.         pop     ax
  157.         pop     bx
  158.         pop     cx
  159.         pop     dx
  160.         ret
  161. print   endp
  162.  
  163. ;********************************************************
  164. ;
  165. ; Output binary AL as 2 hex digits
  166. ;
  167. ;********************************************************
  168.  
  169. print_hex proc  near
  170.         push    bx
  171.         push    ax
  172.         mov     bl,al                   ;isolate HO nibble
  173.         shr     bl,1
  174.         shr     bl,1
  175.         shr     bl,1
  176.         shr     bl,1
  177.         and     bx,0fh
  178.         mov     al,hextab[bx]           ;xlit to hex char
  179.         call    print                   ;print 1st char
  180.         pop     ax
  181.         push    ax
  182.         mov     bl,al                   ;isolate LO nibble
  183.         and     bx,0fh
  184.         mov     al,hextab[bx]           ;xlit to hex char
  185.         call    print                   ;print 2nd char
  186.         pop     ax
  187.         pop     bx
  188.         ret
  189. print_hex endp
  190.  
  191. hextab  db      '0123456789ABCDEF'
  192.  
  193. ;********************************************************
  194. ;
  195. ; Output binary word AX as 4 hex digits
  196. ;
  197. ;********************************************************
  198.  
  199. print_word proc near
  200.         xchg    ah,al                   ;get HO half to AL
  201.         call    print_hex               ;print 1st 2 chars
  202.         xchg    ah,al                   ;get LO half back to AL
  203.         call    print_hex               ;print 2nd 2 chars
  204.         ret
  205. print_word endp
  206.  
  207. ;********************************************************
  208. ;
  209. ; Output binary word AX as 4 hex digits, plus a blank
  210. ;
  211. ;********************************************************
  212.  
  213. print_wordb proc near
  214.         push    ax
  215.         call    print_word
  216.         mov     al,' '
  217.         call    print
  218.         pop     ax
  219.         ret
  220. print_wordb endp
  221.  
  222. ;*****************************************
  223. ;
  224. ; Print CRLF.
  225. ;
  226. ;*****************************************
  227.  
  228. crlf    proc    near
  229.         push    ax
  230.         mov     al,0dh
  231.         call    print
  232.         mov     al,0ah
  233.         call    print
  234.         pop     ax
  235.         ret
  236. crlf    endp
  237.  
  238. ;*****************************************
  239. ;
  240. ; Print string at DS:DX, up to "$" character.
  241. ;
  242. ;*****************************************
  243.  
  244. print_line proc near
  245.         push    si
  246.         push    ax
  247.         cld                     ;forward!
  248.         mov     si,dx           ;DS:SI = string
  249.  
  250. print_line2:
  251.         lodsb                   ;get next byte to print
  252.         cmp     al,'$'          ;terminating char?
  253.         jz      print_line9     ;yes, exit
  254.         call    print           ;print this char
  255.         jmp     print_line2     ;continue till "$"
  256.  
  257. print_line9:
  258.         pop     ax
  259.         pop     si
  260.         ret
  261. print_line endp
  262.  
  263. ;*****************************************
  264. ;
  265. ; Print DX (HO), AX (LO) as xxxx:xxxx.
  266. ;
  267. ;*****************************************
  268.  
  269. print_seg proc  near
  270.         push    ax
  271.         mov     ax,dx           ;get HO word first
  272.         call    print_word
  273.         mov     al,':'          ;show seperator too
  274.         call    print
  275.         pop     ax              ;recover LO word
  276.         call    print_word
  277.         ret
  278. print_seg endp
  279.  
  280. ;********************************************************************
  281. ;
  282. ; Print a line at [DX], edited.
  283. ;
  284. ; Line may contain Edit_xxxx escape characters, as defined above.
  285. ;
  286. ;********************************************************************
  287.  
  288. print_edit proc near
  289.         push    si
  290.         push    dx
  291.         push    cx
  292.         push    bx
  293.         push    ax
  294.         mov     si,dx                   ;use DS:SI to read line
  295.         cld                             ;forward!!!
  296.  
  297. print_edit2:
  298.         lodsb                           ;get next byte of line
  299.         cmp     al,Edit_Byte            ;binary byte to expand?
  300.         jnz     print_edit3             ;no
  301.         lodsb                           ;yes, get 8-bit value
  302.         call    print_hex               ;print it as hex
  303.  
  304. print_edit2b:
  305.         mov     al,'H'                  ;tack "H" for HEX after it
  306.  
  307. print_edit2c:
  308.         call    print
  309.         jmp     print_edit2             ;go get next char
  310.  
  311. print_edit3:
  312.         cmp     al,Edit_Word            ;16-bit binary to expand?
  313.         jnz     print_edit4             ;no
  314.         lodsw                           ;yes, get 16-bit word
  315.         call    print_word              ;display as hex
  316.         jmp     print_edit2b            ;follow with 'H' and continue
  317.  
  318. print_edit4:
  319.         cmp     al,Edit_Call            ;call another routine?
  320.         jnz     print_edit5             ;no
  321.         lodsb                           ;yes, get AH argument
  322.         mov     bh,al                   ;save for a nano...
  323.         lodsw                           ;get DX argument
  324.         mov     dx,ax
  325.         lodsw                           ;get address to call
  326.         mov     cx,ax
  327.         mov     ah,bh                   ;recover AH argument to use
  328.         push    si                      ;save our precious SI
  329.         call    cx                      ;call the routine
  330.         pop     si
  331.         jmp     print_edit2             ;go get next char
  332.  
  333. print_edit5:
  334.         cmp     al,Edit_Dec8            ;8-bit decimal value?
  335.         jnz     print_edit6             ;no
  336.         lodsb                           ;yes, get 8-bit byte
  337.         xor     ah,ah                   ;clear HO byte
  338.  
  339. print_edit5b:
  340.         call    print_dec               ;print AX as decimal
  341.         jmp     print_edit2             ;go get next input char
  342.  
  343. print_edit6:
  344.         cmp     al,Edit_Dec16           ;16-bit decimal value?
  345.         jnz     print_edit7             ;no
  346.         lodsw                           ;yes, get 16-bit byte
  347.         jmp     print_edit5b            ;print it and go get next char
  348.  
  349. print_edit7:
  350.         cmp     al,Edit_End             ;end of input string?
  351.         jnz     print_edit2c            ;no, assume ASCII char and print it
  352.  
  353.         pop     ax
  354.         pop     bx
  355.         pop     cx
  356.         pop     dx
  357.         pop     si
  358.         ret
  359. print_edit endp
  360.  
  361.  
  362. ;**************************************************
  363. ;
  364. ; Print AX in decimal, suppressing leading zeroes
  365. ;
  366. ;**************************************************
  367.  
  368. print_dec proc  near
  369.         push    dx
  370.         push    cx
  371.         push    bx
  372.         push    ax
  373.         mov     cx,10                   ;divisor
  374.         xor     dx,dx
  375.         div     cx                      ;DL=units, AX = answer
  376.         mov     bh,dl                   ;save units
  377.         xor     dx,dx
  378.         div     cx                      ;DL=tens, AX = answer
  379.         mov     bl,dl                   ;get tens
  380.         or      bx,03030h               ;make into 2 ASCII digits
  381.         mov     word ptr dec_buf+3,bx
  382.         div     cl                      ;AH=hunds, AL = answer
  383.         mov     bh,ah                   ;save hundreds
  384.         xor     ah,ah
  385.         div     cl                      ;AH=thous, AL = ten_thousands
  386.         mov     bl,ah                   ;get thous
  387.         or      bx,03030h               ;make into 2 ASCII digits
  388.         mov     word ptr dec_buf+1,bx
  389.         or      al,030h                 ;make ten-thousands into ASCII digit
  390.         mov     byte ptr dec_buf,al
  391.  
  392. ;
  393. ; Now edit out leading zeroes by advancing BX to 1st non-zero
  394. ;
  395.  
  396.         mov     bx,offset dec_buf
  397.         mov     cx,4                    ;max # to suppress
  398.  
  399. print_dec2:
  400.         cmp     byte ptr [bx],'0'
  401.         jnz     print_dec5              ;found non-zero, so exit
  402.         inc     bx                      ;up to next digit
  403.         loop    print_dec2
  404.  
  405. print_dec5:
  406.  
  407. ;
  408. ; All set. Print from [BX] on...
  409. ;
  410.  
  411.         mov     dx,bx
  412.         call    print_line
  413.         pop     ax
  414.         pop     bx
  415.         pop     cx
  416.         pop     dx
  417.         ret
  418. print_dec endp
  419.  
  420. dec_buf db      "99999$"
  421.  
  422.  
  423. ;********************************************************************
  424. ;
  425. ; Print one string from a table of possible strings.
  426. ;
  427. ; On entry: AH holds selector
  428. ;           DX holds table address
  429. ;
  430. ; Each table entry is as follows:
  431. ;
  432. ;       db      <selector>,"string",<term>
  433. ;
  434. ; where:
  435. ;       <selector> is 8-bit byte that is compared with AH. If it
  436. ;                   matches, then this string is printed.
  437. ;
  438. ;       "string" is the string to be printed
  439. ;
  440. ;       <term> is the terminating character, as follows:
  441. ;
  442. ;               00H : end of this string
  443. ;               80H : end of this string, and end of table too
  444. ;
  445. ; If no <selector> matches AH, then "????" is printed.
  446. ;
  447. ;********************************************************************
  448.  
  449. table_print proc near
  450.         push    si
  451.         push    dx
  452.         push    cx
  453.         push    bx
  454.         push    ax
  455.         mov     si,dx                   ;use DS:SI to read table
  456.         cld                             ;forward!!!
  457.  
  458. table_print2:
  459.         lodsb                           ;get next selector
  460.         cmp     al,ah                   ;does it match AH?
  461.         jnz     table_print5            ;no, skip to next one
  462.  
  463. table_print3:
  464.  
  465. ;
  466. ; We have found string to print. Output it until a terminator is found.
  467. ;
  468.  
  469.         lodsb                           ;get byte of string
  470.         test    al,07fh                 ;terminator?
  471.         jz      table_print9            ;yes, exit
  472.         call    print                   ;no, print this char
  473.         jmp     table_print3
  474.  
  475. table_print5:
  476.  
  477. ;
  478. ; Not this selector. Skip over string till terminator, then go peek
  479. ; at next selector.
  480. ;
  481.  
  482.         lodsb                           ;get byte of string
  483.         test    al,07fh                 ;terminator?
  484.         jnz     table_print5            ;no, keep skipping
  485.  
  486. ;
  487. ; We have terminator at end of skipped string. It may be end of whole table...
  488. ;
  489.  
  490.         cmp     al,080h                 ;end of table?
  491.         jnz     table_print2            ;no, go check next selector
  492.         mov     dx,offset huh           ;yes, print "????" message cause match not found
  493.         call    print_line
  494.  
  495. table_print9:
  496.         pop     ax
  497.         pop     bx
  498.         pop     cx
  499.         pop     dx
  500.         pop     si
  501.         ret
  502. table_print endp
  503.  
  504. huh     db      "????$"
  505.  
  506. ;*********************************************
  507. ;
  508. ; Issue extra linefeeds if we're going to the printer. This
  509. ; moves the paper up enough to be read.
  510. ;
  511. ; This should be called before any input, and whenever output is
  512. ; generally finished.
  513. ;
  514. ;*********************************************
  515.  
  516. feed    proc    near
  517.         push    ax
  518.         push    cx
  519.         test    prt_flag,0ffh   ;are we going to the printer?
  520.         jz      feed9           ;no, just exit
  521.         mov     cx,num_feeds    ;# linefeeds to do
  522.         jcxz    feed9           ;none, so exit
  523.  
  524. feed2:
  525.         call    crlf
  526.         loop    feed2
  527.  
  528. feed9:
  529.         pop     cx
  530.         pop     ax
  531.         ret
  532. feed    endp
  533.  
  534.         subttl  Menu Handling
  535.         page
  536. ;*********************************************
  537. ;
  538. ; Get uppercase keyboard char to AL. AH is clobbered.
  539. ;
  540. ;*********************************************
  541.  
  542. key     proc    near
  543.         mov     ah,0            ;use ROM BIOS to read keyboard
  544.         int     016h
  545.         cmp     al,'a'          ;lowercase char?
  546.         jb      key9            ;no
  547.         cmp     al,'z'
  548.         ja      key9            ;likewise no
  549.         and     al,0dfh         ;yes, convert to uppercase
  550. key9:
  551.         ret
  552. key     endp
  553.  
  554. ;*********************************************
  555. ;
  556. ; Reset all ICT hits to zero, and restart trace buffer
  557. ;
  558. ;*********************************************
  559. zapmsg  db    cr,lf,"Counters zeroed",cr,lf,"$"
  560.  
  561. zap_hits proc   near
  562.         push    si
  563.         push    ax
  564.         push    bx
  565.         push    cx
  566.         mov     cx,number_icts          ;Number of ICT's
  567.         xor     si,si                   ;start with # 0
  568.         cli                             ;no interrupts!
  569.  
  570. zap_hits2:
  571.         mov     bx,ict_index[si]        ;[BX] --> ICT
  572.         mov     [bx].ICT_hits,0
  573.         add     si,2                    ;up to next ICT
  574.         loop    zap_hits2               ;till we've done all of them
  575.  
  576.         mov     trace_curr,offset trace_table
  577.         sti                             ;interrupts OK now
  578.         push    dx
  579.         mov     dx,offset zapmsg
  580.         call    print_line
  581.         pop     dx
  582.         pop     cx
  583.         pop     bx
  584.         pop     ax
  585.         pop     si
  586.         ret
  587. zap_hits endp
  588.  
  589. ;**********************************************
  590. ;
  591. ; Pick ICT's with which to do something.
  592. ;
  593. ; This is called to select ICT for various operations.
  594. ;
  595. ; On entry, DX holds address of question (no CRLF's) to be asked.
  596. ;
  597. ; Returns: CARRY SET if user selected ABORT to cancel the caller's operation
  598. ;
  599. ;          CARRY CLEAR if AL has been set to 8-bit pattern, with each
  600. ;          bit from 0 to 7 representing an ICT (0-7) that was selected.
  601. ;
  602. ;**********************************************
  603.  
  604. pick_ict proc   near
  605.         push    bx
  606.         push    cx
  607.         push    dx
  608.         mov     byte ptr pick_map,0     ;init to nobody selected
  609.  
  610. pick_ict1:
  611.  
  612. ;
  613. ; Put up our selection menu
  614. ;
  615.  
  616.         call    crlf
  617.         pop     dx                      ;display caller's question
  618.         push    dx
  619.         call    print_line
  620.         mov     dx,offset pick_menu     ;put up our menu
  621.         call    print_line
  622.  
  623. ;
  624. ; Fill in choices already made, as if he had typed them
  625. ;
  626.  
  627.         mov     cx,number_icts          ;# ICT's
  628.         mov     ah,byte ptr pick_map    ;AH has bitmap
  629.         mov     al,'0'                  ;AL holds ASCII '0' - '7'
  630.  
  631. pick_ict1b:
  632.         test    ah,1                    ;Is this ICT selected?
  633.         jz      pick_ict1c              ;no
  634.         call    print                   ;yes, show corresponding ASCII char
  635.  
  636. pick_ict1c:
  637.         inc     al                      ;Bump ASCII char
  638.         shr     ah,1                    ;get next bit to test
  639.         loop    pick_ict1b              ;till done all 8
  640.         call    feed                    ;eject paper on printer
  641.  
  642. pick_ict2:
  643.  
  644. ;
  645. ; Get and handle next keypress
  646. ;
  647.  
  648.         call    key
  649.         cmp     al,'0'                  ;ICT number?
  650.         jb      pick_ict3               ;no
  651.         cmp     al,'7'
  652.         ja      pick_ict3               ;no
  653.         call    print                   ;yes, echo it
  654.  
  655. ;
  656. ; Convert this ASCII char to bitmap bit, and add to our map
  657. ;
  658.  
  659.         call    bin_to_bit              ;comes back in AL
  660.         or      byte ptr pick_map,al    ;add this new bit into pattern
  661.         jmp     pick_ict2               ;go get next keypress
  662.  
  663. pick_ict3:
  664.         cmp     al,'L'                  ;List ICT's?
  665.         jnz     pick_ict4               ;no
  666.         call    disp_active             ;yes, show all active ICT's
  667.         jmp     pick_ict1               ;give our menu again
  668.  
  669. pick_ict4:
  670.         cmp     al,'R'                  ;Restart?
  671.         jnz     pick_ict5               ;no
  672.         mov     byte ptr pick_map,0     ;yes, clear map
  673.         jmp     pick_ict1               ;give new menu
  674.  
  675. pick_ict5:
  676.         cmp     al,'G'                  ;Go with choices?
  677.         jnz     pick_ict6               ;no
  678.  
  679. pick_ict5b:
  680.         mov     al,byte ptr pick_map    ;yes, get choices as bitmap
  681.         clc                             ;tell caller to use it
  682.         jmp     short pick_ict9         ;exit
  683.  
  684. pick_ict6:
  685.         cmp     al,0dh                  ;Carriage Return?
  686.         jz      pick_ict5b              ;yes, same as "Go"
  687.         cmp     al,'A'                  ;Abort operation?
  688.         jnz     pick_ict7               ;no
  689.  
  690. pick_ict6b:
  691.         stc                             ;tell caller to abort
  692.         jmp     short pick_ict9         ;exit
  693.  
  694. pick_ict7:
  695.         cmp     al,1bh                  ;ESCAPE?
  696.         jz      pick_ict6b              ;yes, same as "Abort"
  697.  
  698. ; ------ Unknown choice
  699.  
  700.         jmp     pick_ict2               ;go get next keypress
  701.  
  702. pick_ict9:
  703.         pop     dx
  704.         pop     cx
  705.         pop     bx
  706.         ret
  707. pick_ict endp
  708.  
  709. pick_menu       db      0dh,0ah
  710.                 db      "0-7 picks ICT   (L)ist ICT's  (A)bort  (R)estart  (G)o with choices"
  711.                 db      0dh,0ah,":$"
  712.  
  713. pick_map        db      0       ;bitmap of selected ICT's
  714.  
  715.  
  716. ;*********************************************
  717. ;
  718. ; Handle "Traces" main menu option
  719. ;
  720. ;*********************************************
  721.  
  722. do_traces proc  near
  723.         push    ax
  724.         push    dx
  725.         mov     dx,offset trace_menu    ;put up our menu
  726.         call    print_line
  727.         call    feed                    ;extra CRLF's for printer
  728.         call    key                     ;get his selection
  729.         cmp     al,'A'                  ;dump All?
  730.         jnz     do_traces2              ;no
  731.         mov     al,0ffh                 ;yes, get bitmap for all ICT's
  732.         jmp     short do_traces7        ;dump 'em
  733.  
  734. do_traces2:
  735.         cmp     al,'S'                  ;Selected ICT's?
  736.         jnz     do_traces9              ;no, so exit
  737.         mov     dx,offset trace_prompt  ;point to question to be used
  738.         call    pick_ict                ;get ICT's as bitmap in AL
  739.         jc      do_traces9              ;user wants to forget about it
  740.  
  741. do_traces7:
  742.  
  743. ;
  744. ; Do dump, with AL holding bitmap of ICT's that are to be included
  745. ;
  746.  
  747.         call    dump_buf                ;with AL already set
  748.  
  749. do_traces9:
  750.         pop     dx
  751.         pop     ax
  752.         ret
  753. do_traces endp
  754.  
  755. trace_menu      db      0dh,0ah
  756.                 db      "Display (A)ll or (S)elected ICTs' traces:$"
  757. trace_prompt    db      "Pick ICT's whose traces are to be included in dump$"
  758.  
  759.  
  760. ;*********************************************
  761. ;
  762. ; Set or Clear F_ENABLE.
  763. ;
  764. ; On entry, AL holds bit value for F_ENABLE (i.e. - ON or OFF).
  765. ;
  766. ; This routine asks user for ICT's to be enabled or disabled.
  767. ;
  768. ;*********************************************
  769.  
  770. do_enable proc  near
  771.         push    si
  772.         push    dx
  773.         push    cx
  774.         push    bx
  775.         push    ax                      ;push him last so we can get to him
  776.  
  777.         mov     dx,offset enable_prompt ;Assume "Enable"
  778.         test    al,F_ENABLE             ;are we enabling?
  779.         jnz     do_enable1              ;yes, we have right message
  780.         mov     dx,offset disable_prompt ;Use "Disable" message
  781.  
  782. do_enable1:
  783.         call    pick_ict                ;get ICT's to be affected
  784.         jc      do_enable9              ;user wants to forget it
  785.         mov     byte ptr enable_map,al  ;save bitmap of ICT's to be done
  786.         xor     si,si                   ;start with ICT #0
  787.         mov     cx,number_icts          ;number of ICT's to look at
  788.  
  789. do_enable2:
  790.         test    byte ptr enable_map,1   ;Should this ICT be done?
  791.         jz      do_enable5              ;no
  792.         mov     bx,ict_index[si]        ;yes, point to ICT
  793.         cli                             ;*** NO INTERRUPTS!!! ***
  794.         pop     ax                      ;get F_ENABLE value
  795.         push    ax
  796.         and     al,F_ENABLE             ;isolate our bit
  797.         mov     ah,[bx].ICT_flags       ;get current flags value
  798.         and     ah,F_ENABLE XOR 0ffh    ;turn off our bit
  799.         or      ah,al                   ;set it per caller's desire
  800.         mov     [bx].ICT_flags,ah       ;replace it in ICT
  801.         STI                             ;*** INTERRUPTS OK NOW ***
  802.  
  803. do_enable5:
  804.         add     si,2                    ;up to next ICT
  805.         shr     byte ptr enable_map,1   ;get next ICT's bitmap bit to Bit 0
  806.         loop    do_enable2              ;till we've looked at all ICT's
  807.  
  808. do_enable9:
  809.         pop     ax
  810.         pop     bx
  811.         pop     cx
  812.         pop     dx
  813.         pop     si
  814.         ret
  815. do_enable endp
  816.  
  817. enable_prompt   db      "Pick ICT's to have tracing ENABLED$"
  818. disable_prompt  db      "Pick ICT's to have tracing DISABLED$"
  819. enable_map      db      0               ;bitmap of ICT's to be altered
  820.  
  821.  
  822.  
  823.  
  824. ;*********************************************
  825. ;
  826. ; Toggle F_FCB in some ICT's.
  827. ;
  828. ;*********************************************
  829.  
  830. do_fcb proc     near
  831.         push    si
  832.         push    dx
  833.         push    cx
  834.         push    bx
  835.         push    ax                      ;push him last so we can get to him
  836.  
  837.         mov     dx,offset fcb_toggle
  838.         call    pick_ict                ;get ICT's to be affected
  839.         jc      do_fcb9                 ;user wants to forget it
  840.         xor     si,si                   ;start with ICT #0
  841.         mov     cx,number_icts          ;number of ICT's to look at
  842.  
  843. do_fcb2:
  844.         test    al,1                    ;Should this ICT be done?
  845.         jz      do_fcb5                 ;no
  846.         mov     bx,ict_index[si]        ;yes, point to ICT
  847.         xor     [bx].ICT_flags,F_FCB    ;toggle current setting
  848.  
  849. do_fcb5:
  850.         add     si,2                    ;up to next ICT
  851.         shr     al,1                    ;get next ICT's bitmap bit to Bit 0
  852.         loop    do_fcb2                 ;till we've looked at all ICT's
  853.  
  854. do_fcb9:
  855.         pop     ax
  856.         pop     bx
  857.         pop     cx
  858.         pop     dx
  859.         pop     si
  860.         ret
  861. do_fcb endp
  862.  
  863. fcb_toggle      db      "Pick ICT's to have F_FCB toggled$"
  864.  
  865.         subttl  Reporting Routines
  866.         page
  867. ;**************************************************
  868. ;
  869. ; Dump trace buffer for ICT's represented by bitmap in AL.
  870. ;
  871. ; If bit n in AL is set, then ICT n's trace records are to be included
  872. ; in dump.
  873. ;
  874. ;**************************************************
  875.  
  876.  
  877. dump_buf proc   near
  878.         push    di
  879.         push    si
  880.         push    dx
  881.         push    cx
  882.         push    bx
  883.         push    ax                      ;push bitmap last so that we can get to it
  884.         xor     di,di                   ;di is printed line counter
  885.         mov     si,offset trace_table   ;start at front of buf
  886.  
  887. dump_buf2:
  888.         cmp     si,trace_curr            ;done whole buffer?
  889.         jae     dump_buf9               ;yes, exit
  890.  
  891. ;
  892. ; Let a keypress interrupt us
  893. ;
  894.  
  895.         mov     ah,1                    ;ROM BIOS "Check for keypress" func
  896.         int     016h                    ;keypress present?
  897.         jnz     dump_buf9               ;yes, exit
  898.  
  899.         mov     al,[si].B_type          ;get ICT #
  900.         call    bin_to_bit              ;convert to bitmap bit
  901.         pop     bx                      ;peek at caller's requested bitmap
  902.         push    bx
  903.         and     bl,al                   ;is this ICT included in caller's bitmap?
  904.         jz      dump_buf5               ;no, skip it
  905.  
  906. ;
  907. ; See if it's time for title line
  908. ;
  909.  
  910.         test    di,07h                  ;every 8 lines
  911.         jnz     dump_buf4               ;not time for title line
  912.         mov     dx,offset dump_title    ;print title line
  913.         call    print_line
  914.  
  915. dump_buf4:
  916.         call    dump_rec                ;dump this record
  917.         inc     di                      ;bump # lines printed
  918.  
  919. dump_buf5:
  920.  
  921. ;
  922. ; Skip over this record, to next one. To do that, we need to know what
  923. ; type of record it is, so that we know how big a record
  924. ; we have to skip over.
  925. ;
  926.  
  927.         mov     bl,[si].B_type          ;get trace record type
  928.         and     bx,11110000b            ;isolate type itself
  929.         shr     bx,1                    ;develop type times 2
  930.         shr     bx,1
  931.         shr     bx,1
  932.         add     si,rec_sizes[bx]        ;add record size to current pointer
  933.         jmp     dump_buf2               ;continue till buffer exhausted
  934.  
  935. dump_buf9:
  936.         pop     ax
  937.         pop     bx
  938.         pop     cx
  939.         pop     dx
  940.         pop     si
  941.         pop     di
  942.         ret
  943. dump_buf endp
  944.  
  945. dump_title      db      0dh,0ah
  946.                 db      0dh,0ah
  947.                 db      "INT #    AX   BX   CX   DX   ES   DS   SI   DI   BP   SS   SP   CS:IP"
  948.                 db      0dh,0ah
  949.                 db      "--- --   ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---------$"
  950.  
  951. ;***********************************************
  952. ;
  953. ; Given binary number (0-7) in AL, return bitmap in AL with corresponding
  954. ; bit (Bit 0 thru Bit 7) set.
  955. ;
  956. ; AH is zeroed.
  957. ;
  958. ;***********************************************
  959.  
  960. bin_to_bit proc near
  961.         mov     ah,al           ;AH is counter, from 7 to 0
  962.         mov     al,1            ;AL is bitmap, Bit 0 to Bit 7
  963.         and     ah,7            ;constrain input
  964.         jz      bin_to_bit9     ;binary was 0, so return with Bit 0 set
  965.  
  966. bin_to_bit3:
  967.         add     al,al           ;shift bitmap left 1 bit
  968.         dec     ah              ;dec count by one
  969.         jnz     bin_to_bit3
  970.  
  971. bin_to_bit9:
  972.         ret
  973. bin_to_bit endp
  974.  
  975. ;***********************************************
  976. ;
  977. ; Dump trace record at [SI]. This routine prints the common
  978. ; header information, then calls specific routines to expand
  979. ; details.
  980. ;
  981. ;***********************************************
  982.  
  983. dump_rec proc   near
  984.         push    si
  985.         push    dx
  986.         push    cx
  987.         push    bx
  988.         push    ax
  989.  
  990.         call    crlf
  991.         mov     al,[si].B_int           ;get Interrupt #
  992.         call    print_hex               ;show interrupt #
  993.         mov     al,'H'
  994.         call    print
  995.         mov     al,' '
  996.         call    print
  997.         mov     al,[si].B_type          ;get ICT #
  998.         and     al,0fh                  ;less than 15
  999.         call    print_hex               ;show interrupt number
  1000.         mov     al,' '
  1001.         call    print                   ;print a space
  1002.         mov     bl,[si].B_type          ;get trace type
  1003.         and     bx,11110000b            ;isolate type of trace
  1004.         shr     bx,1                    ;develop type times 2
  1005.         shr     bx,1
  1006.         shr     bx,1
  1007.         mov     bx,word ptr dump_table[bx]
  1008.         call    bx                      ;call proper specific routine
  1009.         pop     ax
  1010.         pop     bx
  1011.         pop     cx
  1012.         pop     dx
  1013.         pop     si
  1014.         ret
  1015. dump_rec endp
  1016.  
  1017. ;
  1018. ; Table of routines to handle various record types
  1019. ;
  1020.  
  1021. dump_table      label   word
  1022.                 dw      offset dump_before      ;record type 0 = BEFORE
  1023.                 dw      offset dump_after       ;record type 1 = AFTER
  1024.                 dw      offset dump_fcb         ;record type 2 = FCB
  1025.                 dw      offset dump_asciiz      ;record type 3 = ASCIIZ
  1026.  
  1027. ;***********************************************
  1028. ;
  1029. ; Dump BEFORE record at [SI]
  1030. ;
  1031. ;***********************************************
  1032.  
  1033. dump_before proc near
  1034.         push    si
  1035.         push    dx
  1036.         push    cx
  1037.         push    bx
  1038.         push    ax
  1039.         mov     al,'B'                  ;Display "B" for BEFORE
  1040.         call    print
  1041.         mov     al,' '                  ;plus blank after
  1042.         call    print
  1043.         mov     ax,[si].B_ax
  1044.         call    print_wordb
  1045.         mov     ax,[si].B_bx
  1046.         call    print_wordb
  1047.         mov     ax,[si].B_cx
  1048.         call    print_wordb
  1049.         mov     ax,[si].B_dx
  1050.         call    print_wordb
  1051.         mov     ax,[si].B_es
  1052.         call    print_wordb
  1053.         mov     ax,[si].B_ds
  1054.         call    print_wordb
  1055.         mov     ax,[si].B_si
  1056.         call    print_wordb
  1057.         mov     ax,[si].B_di
  1058.         call    print_wordb
  1059.         mov     ax,[si].B_bp
  1060.         call    print_wordb
  1061.         mov     ax,[si].B_ss
  1062.         call    print_wordb
  1063.         mov     ax,[si].B_sp
  1064.         call    print_wordb
  1065.         mov     dx,[si].B_cs
  1066.         mov     ax,[si].B_ip
  1067.         call    print_seg
  1068.  
  1069. ;
  1070. ; Try to interpret this BEFORE record, to make reading easier
  1071. ;
  1072.  
  1073.         call    interp
  1074.         pop     ax
  1075.         pop     bx
  1076.         pop     cx
  1077.         pop     dx
  1078.         pop     si
  1079.         ret
  1080. dump_before endp
  1081.  
  1082. ;***********************************************
  1083. ;
  1084. ; Dump AFTER record at [SI]
  1085. ;
  1086. ;***********************************************
  1087.  
  1088. dump_after proc near
  1089.         push    si
  1090.         push    dx
  1091.         push    cx
  1092.         push    bx
  1093.         push    ax
  1094.         mov     al,'A'                  ;Display "A" for AFTER
  1095.         call    print
  1096.         mov     al,' '                  ;plus blank after
  1097.         call    print
  1098.         mov     ax,[si].A_ax
  1099.         call    print_wordb
  1100.         mov     ax,[si].A_bx
  1101.         call    print_wordb
  1102.         mov     ax,[si].A_cx
  1103.         call    print_wordb
  1104.         mov     ax,[si].A_dx
  1105.         call    print_wordb
  1106.         mov     ax,[si].A_es
  1107.         call    print_wordb
  1108.         mov     ax,[si].A_ds
  1109.         call    print_wordb
  1110.         mov     ax,[si].A_si
  1111.         call    print_wordb
  1112.         mov     ax,[si].A_di
  1113.         call    print_wordb
  1114.         mov     ax,[si].A_bp
  1115.         call    print_wordb
  1116.  
  1117. ;
  1118. ; Now expand flags byte for clarity
  1119. ;
  1120.  
  1121.         mov     dx,[si].A_flags         ;hold flags in DX
  1122.         mov     si,offset dump_flags    ;SI = next flag's name
  1123.         mov     bx,0fd5h                ;mask of valid bits in flags word
  1124.         mov     cx,12                   ;# bits to walk through
  1125.         cld                             ;forward!!!
  1126.  
  1127. dump_after2:
  1128.         test    bx,1                    ;is this a valid flag bit?
  1129.         jz      dump_after4             ;no, move to next one
  1130.         lodsb                           ;yes, get next name
  1131.         test    dx,1                    ;is bit set?
  1132.         jnz     dump_after3             ;yes, use name
  1133.         mov     al,' '                  ;no, use blank
  1134.  
  1135. dump_after3:
  1136.         call    print                   ;print flag name or space
  1137.  
  1138. dump_after4:
  1139.         shr     dx,1                    ;shift flags so next flag is in bit 0
  1140.         shr     bx,1                    ;ditto for mask
  1141.         loop    dump_after2             ;till done all 12 bits
  1142.  
  1143.         pop     ax
  1144.         pop     bx
  1145.         pop     cx
  1146.         pop     dx
  1147.         pop     si
  1148.         ret
  1149. dump_after endp
  1150.  
  1151. dump_flags      db      "CPAZSTIDO"
  1152.  
  1153.  
  1154. ;***********************************************
  1155. ;
  1156. ; Dump FCB record at [SI]
  1157. ;
  1158. ;***********************************************
  1159.  
  1160. dump_fcb proc near
  1161.         push    si
  1162.         push    dx
  1163.         push    cx
  1164.         push    bx
  1165.         push    ax
  1166.         mov     al,[si].FCB_drive       ;display drive # as number
  1167.         mov     byte ptr fcb_drv,al
  1168.         mov     dx,offset fcb_line      ;and put up rest of header
  1169.         call    print_edit
  1170.         add     si,3                    ;skip to filename field
  1171.         mov     cx,8                    ;max # chars to display
  1172.         cld                             ;forward!!!
  1173.  
  1174. dump_fcb2:
  1175.         lodsb                           ;get byte of filename
  1176.         cmp     al,020h                 ;control char or blank?
  1177.         jbe     dump_fcb3b              ;yes, we're done with name
  1178.         call    print                   ;no, display char as-is
  1179.         loop    dump_fcb2               ;till 8 done or early exit
  1180.         jmp     short dump_fcb4
  1181.  
  1182. dump_fcb3:                              ;skip over rest of filename
  1183.         lodsb
  1184.  
  1185. dump_fcb3b:
  1186.         loop    dump_fcb3
  1187.  
  1188. dump_fcb4:                              ;output extension too
  1189.         mov     al,'.'                  ;seperate it with period
  1190.         call    print
  1191.         mov     cx,3                    ;# extension bytes to print
  1192.  
  1193. dump_fcb5:
  1194.         lodsb                           ;get byte of extension
  1195.         cmp     al,020h                 ;control char?
  1196.         jb      dump_fcb6               ;yes, skip it
  1197.         call    print                   ;no, use as-is
  1198.  
  1199. dump_fcb6:
  1200.         loop    dump_fcb5
  1201.         pop     ax
  1202.         pop     bx
  1203.         pop     cx
  1204.         pop     dx
  1205.         pop     si
  1206.         ret
  1207. dump_fcb endp
  1208.  
  1209.  
  1210. fcb_line        label   byte
  1211.                 db      "FCB Drive:"
  1212.                 db      Edit_Dec8
  1213. fcb_drv         db      0
  1214.                 db      " Filename: "
  1215.                 db      Edit_End
  1216.  
  1217. ;***********************************************
  1218. ;
  1219. ; Dump ASCIIZ record at [SI]
  1220. ;
  1221. ;***********************************************
  1222.  
  1223. dump_asciiz proc near
  1224.         push    si
  1225.         push    dx
  1226.         push    cx
  1227.         push    bx
  1228.         push    ax
  1229.         mov     dx,offset asciiz_line   ;put up header
  1230.         call    print_line
  1231.         add     si,2                    ;skip to start of ASCIIZ text
  1232.         mov     cx,size ASCIIZ          ;max # chars to display
  1233.         sub     cx,2                    ;(minus 2 for header)
  1234.         cld                             ;forward!!!
  1235.  
  1236. dump_asciiz5:
  1237.         lodsb                           ;get byte of extension
  1238.         or      al,al                   ;NUL terminator?
  1239.         jz      dump_asciiz9            ;yes, exit
  1240.         cmp     al,020h                 ;control char?
  1241.         jb      dump_asciiz6            ;yes, skip it
  1242.         call    print                   ;no, use as-is
  1243.  
  1244. dump_asciiz6:
  1245.         loop    dump_asciiz5
  1246.  
  1247. dump_asciiz9:
  1248.         pop     ax
  1249.         pop     bx
  1250.         pop     cx
  1251.         pop     dx
  1252.         pop     si
  1253.         ret
  1254. dump_asciiz endp
  1255.  
  1256.  
  1257. asciiz_line     label   byte
  1258.                 db      "ASCIIZ: $"
  1259.  
  1260.  
  1261. ;*****************************************
  1262. ;
  1263. ; Display what we know about ICT # AL (0-7).
  1264. ;
  1265. ;*****************************************
  1266.  
  1267. ict_dump proc   near
  1268.         push    dx
  1269.         push    bx
  1270.         push    ax
  1271.  
  1272.         and     ax,number_icts*2-1      ;edit ICT #
  1273.         mov     bx,ax                   ;get ICT # times 2
  1274.         shl     bx,1                    ;divide by 2
  1275.         mov     bx,ict_index[bx]        ;[BX] --> ICT itself
  1276.  
  1277.         mov     byte ptr ict_msgno,al   ;insert it into message
  1278.         mov     dx,offset ict_msg1      ;"ICT #n at ..."
  1279.         call    print_edit
  1280.  
  1281.         mov     dx,ds                   ;display seg:offset of ICT
  1282.         mov     ax,bx
  1283.         call    print_seg
  1284.  
  1285.         mov     dx,offset ict_ena       ;show whether enabled or disabled
  1286.         test    [bx].ICT_flags,F_ENABLE
  1287.         jnz     ict_dump2               ;got right message
  1288.         mov     dx,offset ict_dis       ;get other message
  1289.  
  1290. ict_dump2:
  1291.         call    print_line              ;display "ENABLED" or "DISABLED"
  1292.  
  1293.         mov     dx,offset ict_msg2      ;"INT xxH "
  1294.         call    print_line
  1295.         mov     al,[bx].ICT_intnum      ;display interrupt #
  1296.         call    print_hex
  1297.  
  1298.         mov     dx,offset ict_msg3      ;"AH range ll/hh"
  1299.         call    print_line
  1300.         mov     al,[bx].ICT_AH_lo       ;display AH range lower limit
  1301.         call    print_hex
  1302.         mov     al,'/'                  ;add seperator
  1303.         call    print
  1304.         mov     al,[bx].ICT_AH_hi       ;display AH range upper limit
  1305.         call    print_hex
  1306.  
  1307.         mov     al,'*'                  ;display '*' if FCB/ASCIIZ set
  1308.         test    [bx].ICT_flags,F_FCB
  1309.         jnz     ict_dump3               ;it's set
  1310.         mov     al,' '                  ;not set, so use blank
  1311.  
  1312. ict_dump3:
  1313.         call    print
  1314.  
  1315.         mov     dx,offset ict_msg4      ;"Exit: RET/RET2/IRET"
  1316.         call    print_line
  1317.         mov     al,[bx].ICT_flags       ;interpret exit type
  1318.         mov     dx,offset ict_exit      ;get to first 6-char message
  1319.         test    al,F_RET
  1320.         jz      ict_dump5               ;not this one
  1321.         call    print_line
  1322.  
  1323. ict_dump5:
  1324.         add     dx,6                    ;up to next 6-char exit name
  1325.         test    al,F_RET2
  1326.         jz      ict_dump6               ;not this one
  1327.         call    print_line
  1328.  
  1329. ict_dump6:
  1330.         add     dx,6                    ;up to next 6-char exit name
  1331.         test    al,F_IRET
  1332.         jz      ict_dump7               ;not this one
  1333.         call    print_line
  1334.  
  1335. ict_dump7:
  1336.         mov     dx,offset ict_msg4a     ;"Hits: "
  1337.         call    print_line
  1338.         mov     ax,[bx].ICT_hits
  1339.         call    print_dec
  1340.  
  1341.         pop     ax
  1342.         pop     bx
  1343.         pop     dx
  1344.         ret
  1345.  
  1346. ict_msg1        db      0dh,0ah,"ICT# ",edit_dec8
  1347. ict_msgno       db      ?," ",edit_end
  1348.  
  1349. ict_msg1a       db      " @ $"
  1350. ict_msg2        db      " INT $"
  1351. ict_msg3        db      "H AH:$"
  1352. ict_msg4        db      " Exit:$"
  1353. ict_msg4a       db      "Hits: $"
  1354. ict_exit        db      "RET  $"        ;6-char exit type names
  1355.                 db      "RET2 $"
  1356.                 db      "IRET $"
  1357. ict_ena         db      " ENABLED $"
  1358. ict_dis         db      " DISABLED$"
  1359.  
  1360. ict_dump endp
  1361.  
  1362.  
  1363. ;*********************************************
  1364. ;
  1365. ; Display all active ICT's
  1366. ;
  1367. ;*********************************************
  1368.  
  1369. disp_active     proc    near
  1370.         push    si
  1371.         push    ax
  1372.         push    bx
  1373.         push    cx
  1374.  
  1375.         mov     cx,number_icts          ;Number of ICT's
  1376.         xor     si,si                   ;start with # 0
  1377.  
  1378. disp_active2:
  1379.         mov     bx,ict_index[si]        ;[BX] --> ICT
  1380.         test    [bx].ICT_flags,F_ACTIVE ;Is this ICT active?
  1381.         jz      disp_active5            ;no, skip it
  1382.         mov     ax,si                   ;yes, develop ICT # 0-7
  1383.         shr     ax,1                    ;divide by 2
  1384.         call    ict_dump                ;display it
  1385.  
  1386. disp_active5:
  1387.         add     si,2                    ;up to next ICT
  1388.         loop    disp_active2            ;till we've done all of them
  1389.         pop     cx
  1390.         pop     bx
  1391.         pop     ax
  1392.         pop     si
  1393.         ret
  1394. disp_active endp
  1395.  
  1396. code    ends
  1397.         end    
  1398.  
  1399.